package com.fudan.adse.controller;

import com.fudan.adse.api.CommonResult;
import com.fudan.adse.domain.po.Location;
import com.fudan.adse.domain.vo.LevelLocationVO;
import com.fudan.adse.service.LocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 地理位置控制器
 *
 * @author Jerry Zhang
 * create: 2022-11-25 15:15
 */
@RestController
@RequestMapping("/api/v1/lms")
public class LocationController {
    @Autowired
    private LocationService locationService;

    @GetMapping("/locations")
    public CommonResult<List<LevelLocationVO>> getAllLocationsBY(
            @RequestParam(value = "province", required = false) String province,
            @RequestParam(value = "city", required = false) String city,
            @RequestParam(value = "town", required = false) String town) {
        return CommonResult.success(locationService.getAllLocationsByCondition(province,city,town));
    }
}
